package com.qidi.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 * http://localhost:8084/actuator/hystrix.stream
 *http://localhost:8761/hystrix
 */
@RestController(value = "UserController")
@RequestMapping({ "/test" })
public class UserController {
    

    @RequestMapping(value = "/user")
    @HystrixCommand(fallbackMethod = "fallback", threadPoolProperties = {
            @HystrixProperty(name = "coreSize", value = "30"), @HystrixProperty(name = "maxQueueSize", value = "100"),
            @HystrixProperty(name = "queueSizeRejectionThreshold", value = "20") }, commandProperties = {  
                    @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "3000"),  
                    @HystrixProperty(name = "circuitBreaker.requestVolumeThreshold", value = "1")  
  
    })
    public Object getUser1() throws InterruptedException{
        return "xxxxxxxxx";
    }

    public Object fallback(Throwable e) {
        e.printStackTrace();
        return "出错了";
    } 
}
